package tree;


import java.util.ArrayList;
import java.util.List;

public class TreeService {
	private XzqDao xzqDao=new XzqDao();

    public TreeNode<XzqEntity> tree(){
        List<XzqEntity> list = xzqDao.select();

        List<TreeNode<XzqEntity>> nodes = new ArrayList<TreeNode<XzqEntity>>();

        //����������תΪ���ڵ�
        for(XzqEntity xzq : list){
            TreeNode<XzqEntity> node = new TreeNode<XzqEntity>();

            //�ڵ�id
            node.setId(xzq.getAddvcd().toString());

            //�ڵ��ϼ�id
            node.setParentId(xzq.getPaddvcd().toString());

            node.setText(xzq.getAddvnm());
            node.setWellcode(xzq.getWellcode());
            if(xzq.getAddvcd().equals("1001000000")){
            	node.setOpen(true);
            }
            if(xzq.getAddvcd().equals("1002000000")){
            	node.setOpen(true);
            }
            if(xzq.getAddvcd().equals("1001070000")){
            	node.setOpen(true);
            }
            if(xzq.getAddvcd().equals("1000000000")){
            	node.setOpen(true);
            }
            
//            node.setNodeData(xzq);
            nodes.add(node);
        }

        return TreeNode.buildTree(nodes);
    }
}
